LAB-2: Data Visualization and Publication¶

Title Description
(I) Import libraries Import and Initialize python libraries.
(II) Starfish A shape made using curves in 'Matplotlib'.
(III) 3d Scatter of Iris Each point represents an iris flower with its position determined by its sepal length, sepal width, and petal width..
(IV) BiVariate Guasssian A Gaussian Bivariate plotted using seaborn
(V) Connect with me Links to my GitHub and LinkedIn profiles

(I) Import libraries¶

In [54]:
import matplotlib.pyplot as plt
import numpy as np
import plotly.express as px
import plotly.graph_objects as go
import seaborn as sns
import plotly.io as pio
pio.renderers.default = 'notebook'

(II) Starfish¶

In [55]:
a = np.linspace(0, 2*np.pi, 100)
r1 = 0.5 + 0.5*np.sin(6*a)
r2 = 0.5 + 0.5*np.cos(6*a)

x1 = r1 * np.cos(a)
y1 = r1 * np.sin(a)
x2 = r2 * np.cos(a)
y2 = r2 * np.sin(a)

fig = plt.figure(facecolor='lightgrey')
plt.plot(x1, y1, 'y')
plt.plot(x2, y2, 'r')

plt.title('Starfish Shape')
Out[55]:
Text(0.5, 1.0, 'Starfish Shape')

(III) 3d Scatter of Iris¶

In [56]:
df = px.data.iris()
fig = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width',
              color='species')
fig.show()

(IV) Bivariate Gaussian¶

In [57]:
sns.set_theme(style="darkgrid")

n = 10000
mean = [0, 0]
cov = [(2, .4), (.4, .2)]
rng = np.random.RandomState(1)
x, y = rng.multivariate_normal(mean, cov, n).T

f, ax = plt.subplots(figsize=(6, 6))
sns.scatterplot(x=x, y=y, s=5, color=".15")
sns.histplot(x=x, y=y, bins=50, pthresh=.1, cmap="mako")
sns.kdeplot(x=x, y=y, levels=5, color="w", linewidths=1)
Out[57]:
<Axes: >

Connect with on GitHub and LinkedIn¶

Thank you